-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow passing custom key to BatchLoader#batch #12
Conversation
lib/batch_loader/executor_proxy.rb
Outdated
@default_value = default_value | ||
@block = block | ||
@block_hash_key = block.source_location | ||
@block_hash_key = key || block.source_location |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I'm overthinking this, but I can see a case for wanting the key to be key.to_s + block.source_location
(allows the key to be unique on a per loader basis, rather than codebase wide) and I cannot see a case for not wanting it to be key.to_s + block.source_location
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think that's a great idea!
Even though with metaprogramming (eval
) key
should be still unique through the whole codebase, in rest of the cases it is very useful and may help avoid potential collisions.
Released it in the |
Thank you for all the work you put into this gem and thank you to all who worked on this PR. It now allows to generate code to avoid boilerplate in common patterns, so I wrote a mixin using batch-loader to generate lazy active record associations. I've also packaged it as a gem in case it is useful to others: https://github.com/mathieul/batch-loader-active-record. |
@mathieul wow, looks awesome! 😍 I remember some people on Reddit were willing to have Thank you for sharing! |
No description provided.